package impl.sort;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tomi
 * Date: 23/08/2011
 * Time: 17:13:19
 * To change this template use File | Settings | File Templates.
 */
public class SelectionSorter extends AbstractSorter {
    public SelectionSorter(){
        super(SorterType.SELECTION);
    }
    public <T> void sort(Comparator<T> c, List<T> list){
        for(int i=0; i<list.size()-1; i++){
            int iMenor = i;
            for(int j=i+1; j<list.size(); j++){
                if(greater(c, list, iMenor, j)){
                    iMenor = j;
                }
            }
            swap(list, iMenor, i);
        }
    }
}